unit DModule;

interface

uses
  SysUtils, Classes,Forms, FIBDatabase,IniFiles, pFIBDatabase, DB, FIBDataSet,
   pFIBDataSet;

type
  Tdm1 = class(TDataModule)
    db1: TpFIBDatabase;
    trnRD: TpFIBTransaction;
    trnWr: TpFIBTransaction;
    DS_Srv_lookup: TpFIBDataSet;
    ds_Kontragent: TpFIBDataSet;
    STATE: TFIBBooleanField;
    CODE: TFIBStringField;
    NAME: TFIBStringField;
    ADDR: TFIBStringField;
    POSTADDR: TFIBStringField;
    INN: TFIBStringField;
    KPP: TFIBStringField;
    FAX: TFIBStringField;
    PHONE: TFIBStringField;
    BANK: TFIBStringField;
    BIK: TFIBStringField;
    SCHET: TFIBStringField;
    KSCHET: TFIBStringField;
    DOPCODE: TFIBStringField;
    ds_Schet: TpFIBDataSet;
    ds_SchetSTATE: TFIBBooleanField;
    ds_SchetCODE: TFIBStringField;
    ds_SchetMASTER: TFIBStringField;
    ds_SchetADDR: TFIBStringField;
    ds_SchetADDR_NAME: TFIBStringField;
    ds_SchetKONTRAGENT: TFIBStringField;
    ds_SchetKONTRAGENT_NAME: TFIBStringField;
    ds_SchetDATE_OPEN: TFIBDateField;
    ds_SchetDATE_CLOSE: TFIBDateField;
    ds_SchetTOTAL_SQ: TFIBBCDField;
    ds_SchetLIVING_SQ: TFIBBCDField;
    ds_SchetLODGER_CNT: TFIBSmallIntField;
    ds_SchetPHONE: TFIBStringField;
    ds_SchetTYPEFLAT: TFIBStringField;
    ds_SchetTYPEFLAT_NAME: TFIBStringField;
    ds_SchetPHONE1: TFIBStringField;
    ds_SchetPHONE2: TFIBStringField;
    ds_SchetPHONE3: TFIBStringField;
    DS_Kontragent_lookup: TpFIBDataSet;
    ds_Srv: TpFIBDataSet;
    ds_SrvSTATE: TFIBBooleanField;
    ds_SrvCODE: TFIBStringField;
    ds_SrvNAME: TFIBStringField;
    DS_TypeFlat_lookup: TpFIBDataSet;
    DS_Addr_lookup: TpFIBDataSet;
    FDS_Addr: TpFIBDataSet;
    blft_AddrSTATE: TFIBBooleanField;
    strft_AddrCODE: TFIBStringField;
    strft_AddrNAME: TFIBStringField;
    strft_AddrZONE: TFIBStringField;
    strft_AddrZONE_NAME: TFIBStringField;
    strft_AddrSTREET: TFIBStringField;
    strft_AddrSTREET_NAME: TFIBStringField;
    strft_AddrHOUSE: TFIBStringField;
    strft_AddrFLAT: TFIBStringField;
    strft_AddrVIDFLAT: TFIBStringField;
    strft_AddrVIDFLAT_NAME: TFIBStringField;
    FDS_Street: TpFIBDataSet;
    blft_StreetSTATE: TFIBBooleanField;
    strft_StreetCODE: TFIBStringField;
    strft_StreetNAME: TFIBStringField;
    FDS_Street_Lookup: TpFIBDataSet;
    FDS_TypeFlat: TpFIBDataSet;
    blft_TypeFlatSTATE: TFIBBooleanField;
    strft_TypeFlatCODE: TFIBStringField;
    strft_TypeFlatNAME: TFIBStringField;
    FDS_VidFlat: TpFIBDataSet;
    blft_VidFlatSTATE: TFIBBooleanField;
    strft_VidFlatCODE: TFIBStringField;
    strft_VidFlatNAME: TFIBStringField;
    FDS_VidFlat_lookup: TpFIBDataSet;
    FDS_Zone: TpFIBDataSet;
    blft_ZoneSTATE: TFIBBooleanField;
    strft_ZoneCODE: TFIBStringField;
    strft_ZoneNAME: TFIBStringField;
    FDS_Zone_lookup: TpFIBDataSet;
    FDS_Users: TpFIBDataSet;
    blft_UsersSTATE: TFIBBooleanField;
    FDS_UsersCODE: TFIBIntegerField;
    strft_UsersNAME: TFIBStringField;
    FDS_UsersLASTTIME: TFIBDateTimeField;
    SmilintFt_UsersBASECODE: TFIBSmallIntField;
    strft_UsersPROFILES: TFIBStringField;
    strft_UsersPSW: TFIBStringField;
    ds_KontragentISUTSK: TBooleanField;
    procedure DataModuleCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  dm1: Tdm1;

implementation

uses common, DataSetEvents;

{$R *.dfm}

procedure Tdm1.DataModuleCreate(Sender: TObject);
var
  ini :TIniFile;
begin
 if ParamStr(1)<>'' then
 begin
   db1.DatabaseName:=ParamStr(1);
   db1.ConnectParams.UserName:='sysdba';
   db1.ConnectParams.Password:='masterkey';
   try
    db1.Connected:=True;
    trnRD.StartTransaction;
    trnWr.StartTransaction;
    MainDb:=db1;
    ini:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'forms.ini');
    ini.WriteString('LastConnect','path',db1.DatabaseName);
   finally

    ini.Free;
   end;
  end;
end;

end.
